<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>MapInfo TAB and MIF/MID</title>
</head>

<body bgcolor="#ffffff">

<h1>MapInfo TAB and MIF/MID</h1>

<p>
MapInfo datasets in native (TAB) format and in interchange (MIF/MID) format
are supported for reading and writing. Starting with GDAL 2.0, update of
existing TAB files is supported (append of new features, modifications and
deletions of existing features, adding/renaming/deleting fields, ...).
Update of existing MIF/MID files is not supported.
</p>

<p>
Note: In the rest of this document "MIF/MID File" is used to refer to a
pair of .MIF + .MID files, and "TAB file" refers to the set of files for a
MapInfo table in binary form (usually with extensions .TAB, .DAT, .MAP, .ID,
.IND).
</p>

<p>
The MapInfo driver treats a whole directory of files as a dataset, and
a single file within that directory as a layer.  In this case the directory
name should be used as the dataset name.
</p>

<p>
However, it is also possible to use one of the files (.tab or .mif) in a
MapInfo set as the dataset name, and then it will be treated as a dataset
with one single layer.
</p>

<p>
MapInfo coordinate system information is supported for reading and writing.
</p>


<h2>Creation Issues</h2>

<p>
The TAB File format requires that the bounds (geographical extents) of a new
file be set before writing the first feature.
</p>

<p>
There is currently no automated setting of valid default bounds for
each spatial reference system, so for the time being, the MapInfo driver sets the following
default bounds when a new layer is created:
</p>
<ul>
  <li>For a file in LAT/LON (geographic) coordinates: BOUNDS (-180, -90) (180, 90)</li>
  <li>For any other projection: BOUNDS (-30000000, -15000000) (30000000, 15000000)</li>
</ul>

<p>
Starting with GDAL 2.0, it is possible to override those bounds through two
mechanisms.
<ul>
<li> specify a user-defined file that contain projection definitions with bounds.
The name of this file must be specified with the MITAB_BOUNDS_FILE configuration
option.
This allows users to override the
default bounds for existing projections, and to define bounds for new projections
not listed in the hard-coded table in the driver.
The format of the file is a simple text file with one CoordSys string
per line.  The CoordSys lines should follow the MIF specs, and MUST
include the optional Bounds definition at the end of the line, e.g.
<pre>
# Lambert 93 French bounds
CoordSys Earth Projection 3, 33, "m", 3, 46.5, 44, 49.00000000002, 700000, 6600000 Bounds (75000, 6000000) (1275000, 7200000)
</pre>

It is also possible to establish a mapping between a source CoordSys and a
target CoordSys with bounds. Such a mapping is specified by adding a line starting
with "Source = " followed by a CoordSys (spaces before or after the equal sign
do not matter). The following line should start with "Destination = "
followed by a CoordSys with bounds, e.g.
<pre>
# Map generic Lambert 93 to French Lambert 93, Europe bounds
Source      = CoordSys Earth Projection 3, 33, "m", 3, 46.5, 44, 49, 700000, 6600000
Destination = CoordSys Earth Projection 3, 33, "m", 3, 46.5, 44, 49.00000000001, 700000, 6600000 Bounds (-792421, 5278231) (3520778, 9741029)
</pre>

</li>
<li>use the BOUNDS layer creation option (see below)</li>
</ul>
</p>

<p>
If no coordinate system is provided when creating a layer, the projection
case is used, not geographic, which can result in very low precision if
the coordinates really are geographic.  You can add "-a_srs WGS84" to the
<b>ogr2ogr</b> commandline during a translation to force geographic mode.
</p>

<p>
MapInfo feature attributes suffer a number of limitations:
</p>
<ul>
<li> Only Integer, Real and String field types can be created.  The various
list, and binary field types cannot be created.</li>
<li> For String fields, the field width is used to establish storage size in
the .dat file.  This means that strings longer than the field width will be
truncated</li>
<li> String fields without an assigned width are treated as 254 characters.</li>
</ul>

<H3>Dataset Creation Options</h3>

<ul>
<li><b>FORMAT=MIF</b>: To create MIF/MID instead of TAB files (TAB is the default).</li>
<li><b>SPATIAL_INDEX_MODE=QUICK/OPTIMIZED</b>: The default is QUICK force
"quick spatial index mode". In this mode writing files can be about 5 times faster, but
spatial queries can be up to 30 times slower. This can be set to OPTIMIZED in
GDAL 2.0 to generate optimized spatial index.</li>
<li><b>BLOCKSIZE=[512,1024,...,32256]</b> (multiples of 512): (GDAL &gt;= 2.0.2)
Block size for .map files. Defaults to 512.
GDAL 2.0.1 and earlier versions only supported BLOCKSIZE=512 in reading and writing.
MapInfo 15.2 and above creates .tab files with a blocksize of 16384 bytes. Any
MapInfo version should be able to handle block sizes from 512 to 32256.
</ul>

<h3>Layer Creation Options</h3>

<ul>
<li><b>BOUNDS=xmin,ymin,xmax,ymax</b>: (GDAL &gt;=2.0) Define custom layer bounds
to increase the accuracy of the coordinates. Note: the geometry of written features
must be within the defined box.</li>
</ul>

<h3>Compatibility</h3>

<p>
Before v1.8.0 , the driver was incorrectly using a "." as the delimiter for id:
parameters and starting with v1.8.0 the driver uses a comma as the delimiter
was per the OGR Feature Style Specification.
</p>
<h3>See Also</h3>


<ul>
<li> <a href="http://mitab.maptools.org/">MITAB Page</a></li>
</ul>

</body>
</html>
